package com.ruoyi.backstage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.zzw.domain.EmphasisPeople;
import com.ruoyi.zzw.service.TEmphasisPeopleService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重点人员管理Controller
 * 
 * @author ruoyi
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/backstage/EmphasisPeople")
public class BackEmphasisPeopleController extends BaseController
{
    @Autowired
    private TEmphasisPeopleService tEmphasisPeopleService;

    /**
     * 查询重点人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:people:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmphasisPeople emphasisPeople)
    {
        startPage();
        List<EmphasisPeople> list = tEmphasisPeopleService.selectTEmphasisPeopleList(emphasisPeople);
        return getDataTable(list);
    }

    /**
     * 导出重点人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:people:export')")
    @Log(title = "重点人员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EmphasisPeople emphasisPeople)
    {
        List<EmphasisPeople> list = tEmphasisPeopleService.selectTEmphasisPeopleList(emphasisPeople);
        ExcelUtil<EmphasisPeople> util = new ExcelUtil<EmphasisPeople>(EmphasisPeople.class);
        util.exportExcel(response, list, "重点人员管理数据");
    }

    /**
     * 获取重点人员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:people:query')")
    @GetMapping(value = "/{cPeopleId}")
    public AjaxResult getInfo(@PathVariable("cPeopleId") Long cPeopleId)
    {
        return success(tEmphasisPeopleService.selectTEmphasisPeopleByCPeopleId(cPeopleId));
    }

    /**
     * 新增重点人员管理
     */
    @PreAuthorize("@ss.hasPermi('system:people:add')")
    @Log(title = "重点人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmphasisPeople emphasisPeople)
    {
        return toAjax(tEmphasisPeopleService.insertTEmphasisPeople(emphasisPeople));
    }

    /**
     * 修改重点人员管理
     */
    @PreAuthorize("@ss.hasPermi('system:people:edit')")
    @Log(title = "重点人员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmphasisPeople emphasisPeople)
    {
        return toAjax(tEmphasisPeopleService.updateTEmphasisPeople(emphasisPeople));
    }

    /**
     * 删除重点人员管理
     */
    @PreAuthorize("@ss.hasPermi('system:people:remove')")
    @Log(title = "重点人员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cPeopleIds}")
    public AjaxResult remove(@PathVariable Long[] cPeopleIds)
    {
        return toAjax(tEmphasisPeopleService.deleteTEmphasisPeopleByCPeopleIds(cPeopleIds));
    }
}
